package com.ruoyi.yf.service.impl;

import com.ruoyi.system.domain.SysUser;
import com.ruoyi.yf.domain.*;
import com.ruoyi.yf.domain.mobile.NoOutBoxInfo;
import com.ruoyi.yf.mapper.YfDisposeMapper;
import com.ruoyi.yf.service.IYfDisposeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service("yfDisposeService")
public class YfDisposeServiceImpl implements IYfDisposeService{

    @Autowired
    private YfDisposeMapper yfDisposeMapper;


    // 根据条码获取医废信息
    @Override
    public YfTag getYFInfoByYfCode(String codeId) {
        return yfDisposeMapper.getYFInfoByYfCode(codeId);
    }


    // 根据条码查询医废
    @Override
    public YfTag selectYfTagByCodeId(String codeId) {
        return yfDisposeMapper.selectYfTagByCodeId(codeId);
    }


    // 查询未出库的医废列表
    @Override
    public List<YfTag> getNoOutStoreYFlistByStagingId(Long userId, Long stagingId, Long ksId, String day) {
        return yfDisposeMapper.getNoOutStoreYFlistByStagingId(userId, stagingId, ksId, day);
    }


    // 医废装箱，只有10 -> 20
    @Override
    public void yfBoxing(String codeId, String boxCode, Long userId, Date date) {
        yfDisposeMapper.yfBoxing(codeId, boxCode, userId, date);
    }


    // 取消医废装箱，只有20 -> 10
    @Override
    public void yfUnBox(String codeId, Long userId) {
        yfDisposeMapper.yfUnBox(codeId, userId);
    }


    // 根据装箱码查询箱内医废
    @Override
    public List<YfTag> getYFByBoxCode(Long userId, Long hospitalId, Long stagingId, String boxCode) {
        return yfDisposeMapper.getYFByBoxCode(userId, hospitalId, stagingId, boxCode);
    }


    // 查询未装箱袋数、重量；装箱未出库袋数、重量、箱数
    @Override
    public NoOutBoxInfo getNoOutBoxInfo(Long userId, Long hospitalId, Long stagingId) {
        return yfDisposeMapper.getNoOutBoxInfo(userId, hospitalId, stagingId);
    }


    // 查询已装箱未出库箱子列表
    @Override
    public List<YfBox> getBoxedNoOutBoxList(Long userId, Long hospitalId, Long stagingId) {
        return yfDisposeMapper.getBoxedNoOutBoxList(userId, hospitalId, stagingId);
    }


    // 封箱
    @Override
    public void sealingBox(Long userId, String boxCode, Date date) {
        yfDisposeMapper.sealingBox(userId, boxCode, date);
    }


    // 根据箱码查询箱码内统计
    @Override
    public YfBox getInBoxYFPrintByBoxCode(Long userId, String boxCode) {
        return yfDisposeMapper.getInBoxYFPrintByBoxCode(userId, boxCode);
    }

    // 根据暂存点id获取未装箱医废
    @Override
    public List<YfTag> getNoBoxedYFByStagingId(Long userId, Long stagingId, Long ksId, String day) {
        return yfDisposeMapper.getNoBoxedYFByStagingId(userId, stagingId, ksId, day);
    }

    // 查询封箱未装车箱子列表
    @Override
    public List<YfBox> getSealingBoxedNoOutBoxList(Long userId, Long hospitalId, Long stagingId) {
        return yfDisposeMapper.getSealingBoxedNoOutBoxList(userId, hospitalId, stagingId);
    }

    // 按暂存点查询当天出库箱子列表
    @Override
    public List<YfBox> getTodayOutYFBoxList(Long userId, Long hospitalId, Long stagingId) {
        return yfDisposeMapper.getTodayOutYFBoxList(userId, hospitalId, stagingId);
    }

    // 获取医废车列表
    @Override
    public List<YfTruck> getYFTruckList(Long userId, Long disposalId) {
        return yfDisposeMapper.getYFTruckList(userId, disposalId);
    }

    // 按医废车及押运员查询当天装车箱子列表
    @Override
    public List<YfBox> getTodayTruckedYFBoxList(Long userId, Long disposalId, Long truckId) {
        return yfDisposeMapper.getTodayTruckedYFBoxList(userId, disposalId, truckId);
    }

    // 取消医废箱装车
    @Override
    public void yfBoxUnTruck(Long userId, Long disposalId, String boxCode) {
        yfDisposeMapper.yfBoxUnTruck(userId, disposalId, boxCode);
    }

    // 根据箱码查询医废箱
    @Override
    public YfBox selectYfBoxByBoxCode(String boxCode) {
        return yfDisposeMapper.selectYfBoxByBoxCode(boxCode);
    }

    // 医废箱装车
    @Override
    public void yfBoxTrucking(Long userId, Long disposalId, Long truckId, String boxCode, Date date) {
        yfDisposeMapper.yfBoxTrucking(userId, disposalId, truckId, boxCode, date);
    }

    // 巡检根据箱码查询医废箱信息
    @Override
    public YfBox getYFBoxInfoByBoxCode(String codeId) {
        return yfDisposeMapper.getYFBoxInfoByBoxCode(codeId);
    }

    // 扫描诊所科室码查询诊所及科室信息
    @Override
    public YfDept getDeptInfoByScanCode(String deptId) {
        return yfDisposeMapper.getDeptInfoByScanCode(deptId);
    }

    // 查询当天处置公司去诊所收集医废汇总
    @Override
    public List<YfClinic> getCZTodayClinicYFTotal(Long userId, Long disposalId) {
        return yfDisposeMapper.getCZTodayClinicYFTotal(userId, disposalId);
    }

    // 获取当前用户收集未装箱装车医废列表
    @Override
    public List<YfTag> getCollNoTruckYFByCollUserId(Long userId, Long disposalId, String yftype) {
        return yfDisposeMapper.getCollNoTruckYFByCollUserId(userId, disposalId, yftype);
    }

    // 诊所医废封箱打印
    @Override
    public int saveCollToTruckYFlist(List<YfTag> yfList, Long userId, Long disposalId, Long truckId, String boxCode, Date date) {
        return yfDisposeMapper.saveCollToTruckYFlist(yfList,userId, disposalId, truckId, boxCode, date);
    }

    // 查询处置公司去诊所收医废未装箱汇总及今天封箱汇总
    @Override
    public NoOutBoxInfo getCZClinicBoxYFTotal(Long userId, Long disposalId) {
        return yfDisposeMapper.getCZClinicBoxYFTotal(userId, disposalId);
    }

    // 查询诊所收集未装箱医废列表 - 重复打印
    @Override
    public List<YfTag> getClinicCollYF(Long userId, Long disposalId, Long ksId, String day) {
        return yfDisposeMapper.getClinicCollYF(userId, disposalId, ksId, day);
    }

    // 根据押运员查询当天去医院收医废汇总
    @Override
    public List<YfBox> getCZTodaHospitalYFTotal(Long userId, Long disposalId) {
        return yfDisposeMapper.getCZTodaHospitalYFTotal(userId, disposalId);
    }

    // 根据押运员查询今日诊所医废封箱列表
    @Override
    public List<YfBox> getTodayClinicSealingBoxList(Long userId, Long disposalId) {
        return yfDisposeMapper.getTodayClinicSealingBoxList(userId, disposalId);
    }

    // 根据装箱码查询箱内诊所医废
    @Override
    public List<YfTag> getClinicYFByBoxCode(Long userId, Long disposalId, String boxCode) {
        return yfDisposeMapper.getClinicYFByBoxCode(userId, disposalId, boxCode);
    }

    // 根据押运员查询今天装车医废箱列表
    @Override
    public List<YfBox> getTodayTruckYFBoxListByUserId(Long userId, Long disposalId, Long hospitalId) {
        return yfDisposeMapper.getTodayTruckYFBoxListByUserId(userId, disposalId, hospitalId);
    }

    // 获取押运员今日诊所收集医废汇总及报零
    @Override
    public List<YfBox> getClinicTodayYFTotalAndZeroByCollUserId(Long userId, Long disposalId) {
        return yfDisposeMapper.getClinicTodayYFTotalAndZeroByCollUserId(userId, disposalId);
    }

    // 医疗机构报零
    @Override
    public void ClinicCollZeroByUserId(Long userId, String userName, Long disposalId, Long hospitalId) {
        yfDisposeMapper.ClinicCollZeroByUserId(userId, userName, disposalId, hospitalId);
    }

    // 根据医院医废箱码查询箱内医废
    @Override
    public List<YfTag> getHospitalBoxYFListByBoxCode(Long userId, Long disposalId, String boxCode) {
        return yfDisposeMapper.getHospitalBoxYFListByBoxCode(userId, disposalId, boxCode);
    }

    // 根据扫描二维码查询医院信息
    @Override
    public YfBox getHospitalByhospitalId(Long hospitalId) {
        return yfDisposeMapper.getHospitalByhospitalId(hospitalId);
    }

    // 查询医院未装车医废箱列表
    @Override
    public List<YfBox> getHospitalNoTruckYFBoxList(Long userId, Long disposalId, Long hospitalId) {
        return yfDisposeMapper.getHospitalNoTruckYFBoxList(userId, disposalId, hospitalId);
    }

    // 查询医院已收集未装箱医废
    @Override
    public List<YfTag> getCollNoBoxYFByHospitalId(Long userId, Long disposalId, Long hospitalId) {
        return yfDisposeMapper.getCollNoBoxYFByHospitalId(userId, disposalId, hospitalId);
    }

    // 查询诊所今日收集医废
    @Override
    public List<YfTag> getClinicTodayYFListByClinicId(Long userId, Long disposalId, Long hospitalId) {
        return yfDisposeMapper.getClinicTodayYFListByClinicId(userId, disposalId, hospitalId);
    }

    // 诊所医废装箱装车
    @Override
    public void clinicYFBoxingAndTrucking(String codeId, String boxCode, Long userId, Long disposalId,
                                          Long truckId, Date date) {
        yfDisposeMapper.clinicYFBoxingAndTrucking(codeId, boxCode, userId, disposalId, truckId, date);
    }

    // 取消诊所医废装箱，只有30 -> 10
    @Override
    public void clinicYFUnBox(String codeId, Long userId) {
        yfDisposeMapper.clinicYFUnBox(codeId, userId);
    }

    // 查询诊所今日已装箱及全部未封箱医废箱列表
    @Override
    public List<YfBox> getClinicTodayBoxedYFAndNoSealingBoxList(Long userId, Long disposalId, Long truckId) {
        return yfDisposeMapper.getClinicTodayBoxedYFAndNoSealingBoxList(userId, disposalId, truckId);
    }

    // 根据押运员查询当天去诊所装箱医废汇总
    @Override
    public NoOutBoxInfo getCZClinicTodaYFTotal(Long userId, Long disposalId) {
        return yfDisposeMapper.getCZClinicTodaYFTotal(userId, disposalId);
    }

    // 查询诊所未装箱医废列表
    @Override
    public List<YfTag> getClinicNoTruckYFList(Long userId, Long disposalId, Long hospitalId) {
        return yfDisposeMapper.getClinicNoTruckYFList(userId, disposalId, hospitalId);
    }

    // 获取押运员今日诊所装箱医废汇总及报零
    @Override
    public List<YfBox> getClinicTodayBoxedYFTotalAndZero(Long userId, Long disposalId) {
        return yfDisposeMapper.getClinicTodayBoxedYFTotalAndZero(userId, disposalId);
    }

    // 根据押运员查询诊所今日装箱医废
    @Override
    public List<YfTag> getClinicTodayOutYFListByClinicId(Long userId, Long disposalId, Long hospitalId) {
        return yfDisposeMapper.getClinicTodayOutYFListByClinicId(userId, disposalId, hospitalId);
    }

    // 根据医院id查询医院信息
    @Override
    public YfDept getHospitalInfoByHospitalId(Long userId, String code) {
        return yfDisposeMapper.getHospitalInfoByHospitalId(userId, code);
    }

    // 查看医院医废出库量
    @Override
    public List<YfBox> getHospitalYFOutTotal(Long userId, Long disposalId, Long hospitalId, String startDate, String endDate) {
        return yfDisposeMapper.getHospitalYFOutTotal(userId, disposalId, hospitalId, startDate, endDate);
    }

    // 根据二维码查询医废车
    @Override
    public YfTruck getTruckByCode(Long userId, Long disposalId, String truckId) {
        return yfDisposeMapper.getTruckByCode(userId, disposalId, truckId);
    }

    // 根据二维码查询押运员
    @Override
    public SysUser getTruckerByCode(Long userId, Long disposalId, Long truckerId) {
        return yfDisposeMapper.getTruckerByCode(userId, disposalId, truckerId);
    }


    // 入库 -> 出库装车
    @Override
    public void inStoreToOutStoreToTruckYF(String codeId, Long userId, Long truckId, Long truckerId) {
        yfDisposeMapper.inStoreToOutStoreToTruckYF(codeId, userId, truckId, truckerId);
    }

    // 一键出库装车
    @Override
    public void oneKeyOutStoreToTruckYF(Long stagingId, Long userId, Long truckId, Long truckerId) {
        yfDisposeMapper.oneKeyOutStoreToTruckYF(stagingId, userId, truckId, truckerId);
    }

    // 科室医废出库装车
    @Override
    public void oneKSInToOutStoreToTruckYF(Long stagingId, Long ksId, Long userId, Long truckId, Long truckerId) {
        yfDisposeMapper.oneKSInToOutStoreToTruckYF(stagingId, ksId, userId, truckId, truckerId);
    }

    // 选择出库装车
    @Override
    public int saveOutStoreToTruckYFlist(List<YfTag> yfList, Long userId, Long truckId, Long truckerId) {
        return yfDisposeMapper.saveOutStoreToTruckYFlist(yfList, userId, truckId, truckerId);
    }

    // 查询1吨医废正负偏差值
    @Override
    public int getOneTonWeightDeviation() {
        return yfDisposeMapper.getOneTonWeightDeviation();
    }

    // 扫描医疗机构码查询医疗机构及医废暂存点信息
    @Override
    public YfDept getHospitalAndStagingInfoByScanCode(Long userId, String deptId) {
        return yfDisposeMapper.getHospitalAndStagingInfoByScanCode(userId, deptId);
    }

    // 处置公司批量上传医废接口
    @Override
    public int czcompanyBatchSaveYF(List<YfTag> yflist) {
        return yfDisposeMapper.czcompanyBatchSaveYF(yflist);
    }

    // 根据处置公司用户及医废车及医疗机构查询医废(按出库用户)
    @Override
    public List<YfTag> getHospitalTodayYFListByUserAndTruckAndHospital(Long userId, Long disposalId, Long truckId, Long hospitalId) {
        return yfDisposeMapper.getHospitalTodayYFListByUserAndTruckAndHospital(userId, disposalId, truckId, hospitalId);
    }

    // 根据押运员查询当天填报医院医废汇总
    @Override
    public List<YfBox> getCZTBTodayHospitalYFTotal(Long userId, Long disposalId) {
        return yfDisposeMapper.getCZTBTodayHospitalYFTotal(userId, disposalId);
    }

    // 根据押运员及医废车查询医院装车医废列表
    @Override
    public List<YfBox> getTodayOneTruckedYFTotalByTruckerFill(Long userId, Long disposalId, Long truckId) {
        return yfDisposeMapper.getTodayOneTruckedYFTotalByTruckerFill(userId, disposalId, truckId);
    }

    // 查询医废车上未卸车0的医废是否有无箱码的情况
    @Override
    public int getIsTruckYFAllHaveBoxCodeByTruck(Long userId, Long disposalId, Long truckId) {
        return yfDisposeMapper.getIsTruckYFAllHaveBoxCodeByTruck(userId, disposalId, truckId);
    }

    // 查询车上未卸车或未转车医废
    @Override
    public YfBox getTruckedYFByTruckId(Long userId, Long disposalId, Long truckId) {
        return yfDisposeMapper.getTruckedYFByTruckId(userId, disposalId, truckId);
    }

    // 查询车上未卸车或未转车医废箱详情
    @Override
    public List<YfBox> getTruckedYFTotalOrBoxListByTruckId(Long userId, Long disposalId, Long truckId) {
        return yfDisposeMapper.getTruckedYFTotalOrBoxListByTruckId(userId, disposalId, truckId);
    }

    // 小车剩余医废全部装入医废运输车
    @Override
    public void smallTruckYFInBigTruck(Long userId, Long disposalId, Long smallTruckId, Long bigTruckId) {
        yfDisposeMapper.smallTruckYFInBigTruck(userId, disposalId, smallTruckId, bigTruckId);
    }

    // 按箱小车医废装入大车
    @Override
    public void smallTruckOneBoxYFInBigTruck(Long userId, Long disposalId, Long smallTruckId,
                                             Long bigTruckId, String boxCode) {
        yfDisposeMapper.smallTruckOneBoxYFInBigTruck(userId, disposalId, smallTruckId, bigTruckId, boxCode);
    }

}
